﻿#ifndef GLUECHECKPARAM_H
#define GLUECHECKPARAM_H

#endif // GLUECHECKPARAM_H

#include "configManager/configobject.h"
#include "configManager/configobjectarray.h"

class GlueCheckParam : public ConfigObject
{
    Q_OBJECT

    Q_PROPERTY(double resoultion READ resoultion WRITE setResoultion NOTIFY resoultionChanged)
    Q_PROPERTY(double maxGlueWidth READ maxGlueWidth WRITE setMaxGlueWidth NOTIFY maxGlueWidthChanged)
    Q_PROPERTY(double minGlueWidth READ minGlueWidth WRITE setMinGlueWidth NOTIFY minGlueWidthChanged)
    Q_PROPERTY(double aveGlueWidthUpperLimit READ aveGlueWidthUpperLimit WRITE setAveGlueWidthUpperLimit NOTIFY
                   aveGlueWidthUpperLimitChanged)
    Q_PROPERTY(double aveGlueWidthLowerLimit READ aveGlueWidthLowerLimit WRITE setAveGlueWidthLowerLimit NOTIFY
                   aveGlueWidthLowerLimitChanged)

public:
    GlueCheckParam(QObject *parent = nullptr) : ConfigObject(parent)
    {
        init();
    }

    double resoultion() const
    {
        return m_resoultion;
    }

    double maxGlueWidth() const
    {
        return m_maxGlueWidth;
    }

    double minGlueWidth() const
    {
        return m_minGlueWidth;
    }

    double aveGlueWidthUpperLimit() const
    {
        return m_aveGlueWidthUpperLimit;
    }

    double aveGlueWidthLowerLimit() const
    {
        return m_aveGlueWidthLowerLimit;
    }

public slots:
    void setResoultion(double resoultion)
    {
        //        qWarning("Floating point comparison needs context sanity check");
        if (qFuzzyCompare(m_resoultion, resoultion))
            return;

        m_resoultion = resoultion;
        emit resoultionChanged(m_resoultion);
    }

    void setMaxGlueWidth(double maxGlueWidth)
    {
        //        qWarning("Floating point comparison needs context sanity check");
        if (qFuzzyCompare(m_maxGlueWidth, maxGlueWidth))
            return;

        m_maxGlueWidth = maxGlueWidth;
        emit maxGlueWidthChanged(m_maxGlueWidth);
    }

    void setMinGlueWidth(double minGlueWidth)
    {
        //        qWarning("Floating point comparison needs context sanity check");
        if (qFuzzyCompare(m_minGlueWidth, minGlueWidth))
            return;

        m_minGlueWidth = minGlueWidth;
        emit minGlueWidthChanged(m_minGlueWidth);
    }

    void setAveGlueWidthUpperLimit(double aveGlueWidthUpperLimit)
    {
        //        qWarning("Floating point comparison needs context sanity check");
        if (qFuzzyCompare(m_aveGlueWidthUpperLimit, aveGlueWidthUpperLimit))
            return;

        m_aveGlueWidthUpperLimit = aveGlueWidthUpperLimit;
        emit aveGlueWidthUpperLimitChanged(m_aveGlueWidthUpperLimit);
    }

    void setAveGlueWidthLowerLimit(double aveGlueWidthLowerLimit)
    {
        //        qWarning("Floating point comparison needs context sanity check");
        if (qFuzzyCompare(m_aveGlueWidthLowerLimit, aveGlueWidthLowerLimit))
            return;

        m_aveGlueWidthLowerLimit = aveGlueWidthLowerLimit;
        emit aveGlueWidthLowerLimitChanged(m_aveGlueWidthLowerLimit);
    }

signals:
    void resoultionChanged(double resoultion);

    void maxGlueWidthChanged(double maxGlueWidth);

    void minGlueWidthChanged(double minGlueWidth);

    void aveGlueWidthUpperLimitChanged(double aveGlueWidthUpperLimit);

    void aveGlueWidthLowerLimitChanged(double aveGlueWidthLowerLimit);

private:
    double m_resoultion = 0;
    double m_maxGlueWidth = 0;
    double m_minGlueWidth = 0;
    double m_aveGlueWidthUpperLimit = 0;
    double m_aveGlueWidthLowerLimit = 0;
};
